<%@ page language="java" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8" %>
<%@include file="/static/common/taglib.jsp" %>
<%@include file="../../public/commonJs.jsp" %>
<%@include file="../../public/commonCss.jsp" %>
<form class="layui-form" style="padding-left: 50px">
    <input type="hidden" name="id" value="${road.id}">
    <div class="layui-form-item">
        <div class="layui-inline">
            <label class="layui-form-label"><span class="fontRed">*</span>所属分类：</label>
            <div class="layui-input-inline">
                <input type="radio" name="num" value="1" title="武汉"
                       <c:if test="${empty road.num or road.num eq 1}">checked</c:if>  />
                <input type="radio" name="num" value="0" title="汉口"
                       <c:if test="${road.num eq 0}">checked</c:if>/>

            </div>
        </div>
    </div>
    <div class="layui-form-item">
        <div class="layui-inline">
            <label class="layui-form-label"><span class="fontRed">*</span>交路名称：</label>
            <div class="layui-input-inline">
                <input type="text" name="name" lay-verify="required" value="${road.name}" class="layui-input">
            </div>
        </div>
    </div>
    <div class="layui-form-item">
        <div class="layui-inline">
            <label class="layui-form-label"><span class="fontRed">*</span>开始时间：</label>
            <div class="layui-input-inline">
                <input type="time" name="startTime" lay-verify="required" value="${road.startTime}"
                       class="layui-input">
            </div>
        </div>
    </div>
    <div class="layui-form-item">
        <div class="layui-inline">
            <label class="layui-form-label"><span class="fontRed">*</span>结束时间：</label>
            <div class="layui-input-inline">
                <input type="time" name="endTime" lay-verify="required" value="${road.endTime}"
                       class="layui-input">
            </div>
        </div>
    </div>
    <div class="layui-form-item">
        <div class="layui-inline">
            <label class="layui-form-label"><span class="fontRed">*</span>是否临客：</label>
            <div class="layui-input-inline">
                <input type="radio" name="tempTrain" value="1" title="是"
                       <c:if test="${empty road.tempTrain or road.tempTrain eq '1'}">checked</c:if>  />
                <input type="radio" name="tempTrain" value="0" title="否"
                       <c:if test="${road.tempTrain eq '0'}">checked</c:if>/>
            </div>
        </div>
    </div>
    <div class="layui-form-item">
        <div class="layui-inline">
            <label class="layui-form-label"><span class="fontRed">*</span>GSM-R1：</label>
            <div class="layui-input-inline">
                <input type="text" name="gsm1" lay-verify="required" value="${road.gsm1}" class="layui-input">
            </div>
        </div>
    </div>
    <div class="layui-form-item">
        <div class="layui-inline">
            <label class="layui-form-label"><span class="fontRed">*</span>GSM-R2：</label>
            <div class="layui-input-inline">
                <input type="text" name="gsm2" lay-verify="required" value="${road.gsm2}" class="layui-input">
            </div>
        </div>
    </div>
    <div class="layui-form-item">
        <div class="layui-input-block">
            <button class="layui-btn" lay-submit="" lay-filter="demo1">保存</button>
            <button class="layui-btn layui-btn-primary" onclick="closeLayer()">取消</button>
        </div>
    </div>
</form>
<script type="text/javascript">
    var index = parent.layer.getFrameIndex(window.name); //获取窗口索引
    var form = layui.form();
    //监听提交
    form.on('submit(demo1)', function (data) {
        //这里执行ajax提交
        $.ajax({
            type: 'post',
            url: '${ctx}/roadController/saveOrUpdateRoad.action',
            data: data.field,
            dataType: "json",
            timeout: 10000,
            success: function (data) {
                if (data.code == 0) {
                    parent.layer.close(index);
                    parent.layer.msg('操作成功', {icon: 1});
                    parent.loadTableData();
                } else {
                    parent.layer.msg('操作失败', {icon: 2});
                }
            }
        });
        return false;
    });
    form.render();

    //关闭对话框
    function closeLayer() {
        parent.layer.close(index);
    }
</script>
